import React, {Component} from 'react'
import {Link} from 'react-router'
import { Input, Icon, Button,Tooltip } from 'antd';
import './header.scss'

class HeaderComponent extends Component{
   constructor(props){
      super(props);
      this.state = {
        adminifo:null,

      };
   }
   sessionstorageGet = (key) => {
        if (window.sessionStorage) {
          var JsonStr = window.sessionStorage.getItem(key);
          var res = JSON.parse(JsonStr);
          return res;
        } else {
          return "浏览器不支持sessionStorage";
        }
      }
    render(){
        this.state.adminifo = this.sessionstorageGet("adminifo")

        return (
            <div className="dk-header">
                <ul>
                    <li>
                       <Link to="/">
                          <img  src={require('../../../assets/img/react.png')} />
                          <span>React</span>
                       </Link>
                    </li>
                </ul>
                <ul>
                     <li className="user">
                        <span>{this.state.adminifo.username}</span>
                     </li>
                    <li>
                        <Link  to="/">
                            <Tooltip placement="top" title="修改密码">
                                修改密码
                            </Tooltip>
                        </Link>
                    </li>
                    <li>
                        <Link className="dropdown-toggle count-info" to="/">
                            <Tooltip placement="top" title="退出">
                               <Icon type="poweroff" style={{ fontSize: '16px', color: 'white' }} />
                            </Tooltip>
                        </Link>
                    </li>
                </ul>
            </div>
        )
    }
}

export default HeaderComponent


